package com.djmw.mouse.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name = "t_application")
@AssociationOverrides({
    @AssociationOverride(name = "pk.position", joinColumns = @JoinColumn(name = "c_position_id")),
    @AssociationOverride(name = "pk.cvLang", joinColumns = @JoinColumn(name = "c_cv_lang_id")),
    @AssociationOverride(name = "pk.memberUser", joinColumns = @JoinColumn(name = "c_member_user_id"))
})
public class Application implements Serializable {
    private static final long serialVersionUID = 894549618798646095L;

    private ApplicationId pk = new ApplicationId();
    private Date createDate;

    public Application() {
    }

    @EmbeddedId
    public ApplicationId getPk() {
        return pk;
    }
    public void setPk(ApplicationId pk) {
        this.pk = pk;
    }

    @Transient
    public Position getPosition() {
        return pk.getPosition();
    }
    public void setPosition(Position position) {
        pk.setPosition(position);
    }

    @Transient
    public CvLang getCvLang() {
        return pk.getCvLang();
    }
    public void setCvLang(CvLang cvLang) {
        pk.setCvLang(cvLang);
    }

    @Transient
    public MemberUser getMemberUser() {
        return pk.getMemberUser();
    }
    public void setMemberUser(MemberUser memberUser) {
        pk.setMemberUser(memberUser);
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "c_create_date")
    public Date getCreateDate() {
        return createDate;
    }
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Override
    @Transient
    public int hashCode() {
        return pk == null ? 0 : pk.hashCode();
    }
}
